<template>
  <div class="container">
    <div class="login-wrapper">
      <div class="header">登录</div>
      <div class="form-wrapper">
        <div>手机号<el-input v-model="phoneInfo" placeholder="请输入内容"></el-input></div>
        <!-- <el-input v-model="input" placeholder="请输入内容"></el-input> -->
        <div class="btn" @click="login">登录</div>
      </div>
      <!-- <div class="msg">
        Don't have account?
        <a href="#">Sign up</a>
      </div> -->
    </div>
  </div>
</template>

<script>


import axios from "axios";
import {
  getUrl
} from "@/config.js";

export default {
  data() {
    return {
      phoneInfo: "",
      type: "",
      token: "",
      avatar: "",
      mechanismMemberUserId: "",
      qrCode: {
        nickName: "",
        promotionCodeImg: "",
      },
    };
  },
  methods: {
    login() {
      if (this.phoneInfo == "") {
        this.$message.error('请填写手机号');
        return;
      }
      if (!this.checkMobile(this.phoneInfo)) {
        this.$message.error('请填写符合条件的手机号');
        return;
      }
      var baseUrl = getUrl();
      axios.post(
        baseUrl + "/an/h5/h5Login",
        // `https://www.ainaoxingdong.com/api/an/wechat_app/wechat_user/report/bind_img?token=${_this.token}`,
        {
          phone: this.phoneInfo,
          isSuggest: 3
        }
      ).then((res) => {
        if (res.data.code == 200) {
          // debugger
          localStorage.setItem("token", res.data.data.token);
          localStorage.setItem("tokenStartTime", new Date().getTime());
          this.$router.push('/activity')
        } else {
          this.$message.error('登录失败！');
        }
      });
    },
    checkMobile(str) {
      var length = str.length;
      if (length == 11 &&
        /^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(14[0-9]{1})|)+\d{8})$/.test(str)
      ) {
        return true;
      } else {
        return false;
      }
    },
  },
  mounted() {
    localStorage.getItem("");
  },
};
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  height: 100%;
}

.container {
  height: 100%;
  background-image: linear-gradient(to right, #0f842e, #a6c1ee);
}

.login-wrapper {
  background-color: #fff;
  width: 358px;
  height: 588px;
  border-radius: 15px;
  padding: 0 50px;
  position: relative;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.header {
  font-size: 38px;
  font-weight: bold;
  text-align: center;
  line-height: 200px;
}

.input-item {
  display: block;
  width: 100%;
  margin-bottom: 20px;
  border: 0;
  padding: 10px;
  border-bottom: 1px solid rgb(128, 125, 125);
  font-size: 15px;
  outline: none;
}

.input-item:placeholder {
  text-transform: uppercase;
}

.btn {
  text-align: center;
  padding: 10px;
  width: 100%;
  margin-top: 40px;
  background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
  color: #fff;
}

.msg {
  text-align: center;
  line-height: 88px;
}

a {
  text-decoration-line: none;
  color: #abc1ee;
}

.first {
  height: 100%;
  // background-color: pink;
  overflow-x: hidden;
  margin-top: 50%;
}
</style>
